FROM alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/node:20.16 AS build-stage
USER root

RUN rm -f /etc/localtime && ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone

WORKDIR /app

COPY package*.json ./
COPY .npmrc ./

RUN npm config set fetch-timeout 60000  # 设置请求超时时间为 60 秒
RUN npm config set fetch-retries 5      # 设置重试次数

RUN npm install --loglevel=http # --frozen-lockfile

COPY . /app

RUN npm run build

ENV NODE_ENV=production
ENV PORT=8080
EXPOSE 8080
CMD ["npm", "start"]
